function init() {
  var ths = document.getElementsByTagName('th');
  var tbody = document.getElementsByTagName('tbody')[0];
  var rows = document.getElementsByTagName('tr');
  var checkAll = document.getElementsByClassName('checkAll')[0];
  var checklist = tbody.getElementsByTagName('input');

  /* 绑定表头点击事件 */
  // for (let i = 0; i < ths.length; i++) {
  //   ths[i].addEventListener('click', thOnclick);
  // }

  checkAll.addEventListener('click', checkAllOnclick);

  function checkAllOnclick() {
    for (let i = 0; i < ths.length; i++) {
      checklist[i].checked = checkAll.checked;
    }
  }


  for (let i = 0; i < checklist.length; i++) {
    checklist[i].addEventListener('click', onCheckOneClick)
  }

  function onCheckOneClick() {
    var num = 0;
    for (let i = 0; i < checklist.length; i++) {
      checklist[i].checked && ++num;
    }
    checkAll.checked = num === checklist.length
  }




}
init();